package demo1228.pm;

public class SaleTicket1 implements Runnable {
    int tickets = 1000;
    @Override
    public void run() {
        while (tickets>0){
            sale();
        }
    }
//同步方法
    public synchronized void sale() {
        if (tickets>0){
            System.out.println(Thread.currentThread().getName()+
                    "正在售卖第"+tickets+"张票,还有"+ --tickets+"张票");
        }
    }
}
